package org.example.aidemo.controller;

import org.example.aidemo.pojo.Order;
import org.example.aidemo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @GetMapping(value ="/getOrderById", produces = MediaType.APPLICATION_JSON_VALUE)
    public Order getOrderById(@RequestParam(value = "id",defaultValue = "1")
                                   String id) {
        return orderService.getOrderById(id);
    }
    @GetMapping(value ="/getAllOrders", produces = MediaType.APPLICATION_JSON_VALUE)
    public List<Order> getAllOrders() {
        return orderService.getAllOrders();
    }
    @DeleteMapping(value ="/deleteOrderById", produces = MediaType.APPLICATION_JSON_VALUE)
    public Order deleteOrderById(@RequestParam(value = "id",defaultValue = "1")
                                   String id) {
        return orderService.deleteOrderById(id);
    }

}
